const textEncrypt = document.getElementById("text-encrypt");
const btnEncrypt = document.getElementById('btn-encrypt');
const info = document.getElementById("info");


btnEncrypt.addEventListener("click", function (e) {
  globalConfig.secret = textEncrypt.value;
  for (let file of globalConfig.fileInfo) {
    encryptData(file.path, file.path + '.enc');
    info.innerHTML = file.path + "加密完成";
  }
});

const textDecrypt = document.getElementById("text-decrypt");
const btnDecrypt = document.getElementById('btn-decrypt');

btnDecrypt.addEventListener("click", function (e) {
  globalConfig.secret = textDecrypt.value;
  for (let file of globalConfig.fileInfo) {
    let index = file.path.indexOf(".enc");
    decryptData(file.path, index == -1 ? file.path : file.path.substring(0, index));
    info.innerHTML = file.path + "解密完成";
  }
});